<template>
<view>
<!--hotmall/packageC/express/express.wxml-->
<!-- <text>hotmall/packageC/express/express.wxml</text> -->
<view class="one head">
  <view class="wlimg">
    <image src="/static/remao_shop/img/fahuo_icon.png" class></image>
  </view>
  <view class="headText">
    <view>
      <text>物流公司：</text>
      <text>{{logisticsCompany}}</text>
    </view>
    <view>
      <text>物流单号：</text>
      <text>{{orderNumber}}</text>
    </view>
  </view>
</view>
<view v-for="(item, index) in info" :key="index" class="one body" v-if="reason == false" :data-index="index">
  <view>
    <image src="/static/remao_shop/img/dingwei.png" class="bodyImg"></image>
  </view>
  <view>
    <view :class="index == 0?'bodyy':''">[{{item.Location}}]{{item.AcceptStation}}</view>
    <view :class="index == 0?'bodyy':''">{{item.AcceptTime}}</view>
  </view>
</view>
<view class="one body" v-if="reason == true"> 
  <view>
    <image src="/static/remao_shop/img/dingwei.png" class="bodyImg"></image>
  </view>
  <view>
    <view class="zanwu">暂无物流信息</view>
  </view>
</view>
</view>
</template>

<script>
import api from "../../../api";
var app = getApp();

export default {
  data() {
    return {
      index: 0,
      sn: 0,
      logisticsCompany: "京东",
      orderNumber: 0,
      info: [],
      reason: ""
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      sn: options.sn
    });
    this.kdniao();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  methods: {
    kdniao: function () {
      app.globalData.request({
        url: api.gzSea.tracks,
        data: {
          order_sn: this.sn
        },
        method: "POST",
        header: {
          'content-type': "application/x-www-form-urlencoded;charset=utf-8"
        },
        success: success => {
          console.log(success);
          var bchearr = [];

          for (var i = 0; i <= success.Traces.length; i++) {
            bchearr.push(success.Traces.pop());
          }

          bchearr.push(success.Traces[0]);
          console.log(bchearr);
          this.setData({
            logisticsCompany: success.express_com,
            orderNumber: success.LogisticCode,
            info: bchearr
          });

          if (success.Reason) {
            this.setData({
              reason: true
            });
          } else {
            this.setData({
              reason: false
            });
          }
        },
        fail: fail => {
          console.log(fail);
        }
      });
    }
  }
};
</script>
<style>
@import "./express.css";
</style>